<?php
/*
 * @Author: 李明
 * @Date: 2021-12-24 10:54:29
 * @LastEditTime: 2021-12-24 10:55:57
 * @LastEditors: 李明
 * @Description: 
 * @FilePath: /CRM2.0-PHP/app/Http/Controllers/app/bank_card/BankCardController.php
 * @山东壹零贰肆信息科技有限公司
 */

namespace App\Http\Controllers\app\bank_card;

use App\Http\Controllers\common\LMReturn;
use App\Http\Controllers\Controller;
use App\Http\Resources\BankCard as ResourcesBankCard;
use App\Models\BankCard;
use Illuminate\Http\Request;

class BankCardController extends Controller
{

    //银行卡展示
    public function BankCardList(Request $request)
    {
        // 接收参数
        try {
            //去验证token值
            $tokenInfo = json_decode($this->verifyTokenLm("user"), true);
            //判断传递过来的token的code码是否等于400  如果是400的话，提示token不正确
            if ($tokenInfo['code'] == 400) {
                return LMReturn::Error($tokenInfo['msg'], $tokenInfo['code']);
            }
            //接收前端传递过来的值
            $all = $request->all();
        } catch (\Throwable $th) {
            return LMReturn::Error('传参错误', 'BCC003');
        }

        // 参数处理
        try {
            $where = [];
            $where[] = ["user_id", $tokenInfo['user_id']];
        } catch (\Throwable $th) {
            return LMReturn::Error('处理参数发生错误', 'BCC004');
        }
        $bank_card = BankCard::where($where)
            ->with('images')
            ->orderBy("update_time", "desc")
            ->get();
        $bank_card_res = ResourcesBankCard::collection($bank_card);
        return LMReturn::Success($bank_card_res);
    }
}
